$('input[name="oldpassword"]').on("blur",function () {
    var value = $(this).val()
    var password = getpassword();
        function getpassword() {
        $.ajax({
            url:"/user/getpassword" ,
            // dataType:"json",
            type:"get",
            async:false,
            success:function (data) {
                console.log(data)
               password =data
            }
        })
        return password
    }
    console.log(password)
        if ( value == null|| value == '') {
            $("#old_err").html("请输入密码")
        }
        else if (value != password){
            $("#old_err").html("原密码错误请重新输入")
        }
        else {
            $("#old_err").html("")
             f = 1;
        }
})
$('input[name="newpassword"]').on("blur",function () {
    var new1 = $(this).val();
    if (new1==null||new1==''){
        $("#new_err").html("请输入密码")
    }
    else{
        $("#new_err").html("")
        f = 1
    }
})

$('input[name="newpassword1"]').on("blur",function () {
    var new1 = $('input[name="newpassword"]').val();
    var new2 =$('input[name="newpassword1"]').val();
    console.log(new2)
    if (new2==null||new2==''){
        $("#new1_err").html("请确认密码")
    }
    else{
        $("#new1_err").html("")
    }
    if(new1!==new2)
    {
        $("#new1_err").html("两次密码输入不一致，请重新输入")
    }
    else{
        $("#new1_err").html("")
    }
})

function changepassword() {
        var new1 = $('input[name="newpassword1"]').val();
    $.ajax({
        url: "/user/changepwd",
        data: "newpassword=" + new1,
        // dataType: "json",
        type: "post",
        success: function (data) {
            if (data == "success") {
                alert("修改成功")
                setTimeout(function () {
                    location.href = "/person.html"
                }, 1000)
            }
        }
    })
}